package com.game;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.MotionEvent;

public abstract class SlideBar 
{
	protected int m_X, m_Y, m_W, m_H;
	protected int m_CurDis;
	protected Bitmap m_Background;
	
	public SlideBar(int x, int y, int w, int h, Bitmap bg)
	{
		m_X = x;
		m_Y = y;
		m_W = w;
		m_H = h;
		
		m_CurDis = m_X;
		
		m_Background = bg;
	}
	
	public abstract void Draw(Canvas canvas);
	
	public boolean HandleTouch(int tx, int ty) 
	{
		if(PointInArea(tx, ty))
		{
			m_CurDis = tx;
		}
		return true;
	}
	
	protected boolean PointInArea(int x, int y)
	{
		if (x < m_X ) return false;
		if (x > m_X + m_W) return false;
		if (y < m_Y) return false;
		if (y > m_Y + m_H) return false;
		
		return true;			
	}
	
}
